/** SingletonClass ---------------------------------------------------**/
/** Is the abstract class of a singleton
**/

#ifndef SINGLETON_H_
#define SINGLETON_H_

#include <stdlib.h>
#include <boost/shared_ptr.hpp>

namespace BPL
{
template<class T>
class Singleton
{
public:
    static T& instance()
    {
        if(!mpt_inst)
            mpt_inst = new T;

        return *mpt_inst;
    }

    static void destroy()
    {
        delete mpt_inst;
        mpt_inst = NULL;
    }

protected:
    Singleton() {}
    ~Singleton() {}

private:
	static boost::shared_ptr<T> mpt_inst;

    Singleton(Singleton&);
    void operator=(Singleton&);

};

template <class T> boost::shared_ptr<T> Singleton<T>::mpt_inst= boost::shared_ptr<T>(new T());
}
#endif // SINGLETON_H
